/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.colegiatura.be;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author ADMINISTRADOR
 */
@Entity
@Table(name = "col_colegiado_imagen")
//@NamedQueries({@NamedQuery(name = "ColegiadoImagen.findAll", query = "SELECT c FROM ColegiadoImagen c"), @NamedQuery(name = "ColegiadoImagen.findByCimCodigo", query = "SELECT c FROM ColegiadoImagen c WHERE c.cimCodigo = :cimCodigo"), @NamedQuery(name = "ColegiadoImagen.findByCimRuta", query = "SELECT c FROM ColegiadoImagen c WHERE c.cimRuta = :cimRuta")})
public class ColegiadoImagen implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "cim_codigo")
    private Long cimCodigo;
    @Basic(optional = false)
    @Column(name = "cim_ruta")
    private String cimRuta;
    @Column(name = "cim_fechaRegistro")
    @Temporal(TemporalType.DATE)
    private Date cimFechaRegistro;
   
    @JoinColumn(name = "col_codigo", referencedColumnName = "col_codigo")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Colegiado colCodigo;

    @JoinColumn(name = "tim_codigo", referencedColumnName = "tim_codigo")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private TipoImagen timCodigo;


    public ColegiadoImagen() {
    }

    public ColegiadoImagen(Long cimCodigo) {
        this.cimCodigo = cimCodigo;
    }

    public ColegiadoImagen(Long cimCodigo, String cimRuta) {
        this.cimCodigo = cimCodigo;
        this.cimRuta = cimRuta;
    }

    public Long getCimCodigo() {
        return cimCodigo;
    }

    public void setCimCodigo(Long cimCodigo) {
        this.cimCodigo = cimCodigo;
    }

    public String getCimRuta() {
        return cimRuta;
    }

    public void setCimRuta(String cimRuta) {
        this.cimRuta = cimRuta;
    }

    public Colegiado getColCodigo() {
        return colCodigo;
    }

    public void setColCodigo(Colegiado colCodigo) {
        this.colCodigo = colCodigo;
    }

    public TipoImagen getTimCodigo() {
        return timCodigo;
    }

    public void setTimCodigo(TipoImagen timCodigo) {
        this.timCodigo = timCodigo;
    }

    public Date getCimFechaRegistro() {
        return cimFechaRegistro;
    }

    public void setCimFechaRegistro(Date cimFechaRegistro) {
        this.cimFechaRegistro = cimFechaRegistro;
    }

    public String getFechaRegistro(){

        SimpleDateFormat sd =  new SimpleDateFormat("dd/MM/yyyy");
        return sd.format(cimFechaRegistro);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cimCodigo != null ? cimCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ColegiadoImagen)) {
            return false;
        }
        ColegiadoImagen other = (ColegiadoImagen) object;
        if ((this.cimCodigo == null && other.cimCodigo != null) || (this.cimCodigo != null && !this.cimCodigo.equals(other.cimCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.cip.esymons.colegiatura.be.ColegiadoImagen[cimCodigo=" + cimCodigo + "]";
    }

    @Transient
    private String aplication;

    public String getAplication() {
        return aplication;
    }

    public void setAplication(String aplication) {
        this.aplication = aplication;
    }
    

}
